
/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */



/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

require('./bootstrap');
window.Vue = require('vue');
import VueRouter from 'vue-router';

Vue.use(VueRouter);
//引入view-design
import ViewUI from 'view-design';
import 'view-design/dist/styles/iview.css';
Vue.use(ViewUI);
import Vuex from 'vuex'
import store from './store'
Vue.use(Vuex)
import routes from './route';    // 路由配置文件
// 实例化路由
const router = new VueRouter({
    routes
})
router.beforeEach(function(to,from,next){
    if(store.state.userInfo||to.path==='/login'||window.sessionStorage.getItem('userInfo')){
        next();
    }
    else {
        next({path:'/login'})
    }
})
var vm = new Vue({
    router,
    store
}).$mount('#app');